package com.allwees.bs.module.ums.req.query;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.allwees.bs.core.model.coupon.constant.ECashLogType;
import com.allwees.bs.core.modelbase.req.QueryReq;
import com.allwees.bs.module.ums.entity.CustomerCashLog;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = true)
public class CustomerCashLogQueryReq extends QueryReq<CustomerCashLog> {

    private static final long serialVersionUID = -4719327157636055882L;
    private Date createdAtFrom;
    private Date createdAtTo;
    private String userUuid;
    private ECashLogType logType;

    @Override
    public void buildQuery(QueryWrapper<CustomerCashLog> wrapper) {
        wrapper.eq(StringUtils.isNotBlank(userUuid), "user_uuid", userUuid)
                .eq(logType != null, "log_type", logType)
                .gt(createdAtFrom != null, "created_at", createdAtFrom)
                .lt(createdAtTo != null, "created_at", createdAtTo);
    }
}
